Printing apparatus and computer program product

ABSTRACT

In a printing apparatus, the number of delimiters included in received data from a host apparatus is smaller than the number of input items of a template by one. Therefore, the number of delimiters included in the received data from the host apparatus is calculated to be three. A character string which is periodically repeated in the received data three times as the number of the delimiters is obtained and set to be a delimiter candidate. Further, a print start character string candidate is obtained from a data group which is located after a last delimiter candidate in the received data. Using the provisionally determined candidates for a delimiter and a print start character string, the four item data included in the received data are assumed. Then, a print preview is displayed on a LCD so as to show a state where the four item data is input to each of the input items of the template.

CROSS-REFERENCE TO RELATED APPLICATIONS

The present application claims priority from JP 2006-299342, filed onNov. 2, 2006, the disclosure of which is herein incorporated byreference in its entirety.

TECHNICAL FIELD

The disclosure relates to a printing apparatus and a computer programproduct for printing a template where received data is input to inputitems.

BACKGROUND

Conventionally, when a printing apparatus receives data from a hostapparatus such as a scale, a bar code reader, a medical equipment andthe like, item data included in the received data is input to each inputitem of a template of the printing apparatus. The data received from thehost apparatus includes item data, a delimiter, a print start commandand the like. Therefore, a user preliminary registered a delimitercharacter, a print start character and the like which are used by thehost apparatus such that the printing apparatus automatically analyzesthe item data, a delimiter, a print start command and the like based onthe data received from the host apparatus. After such initial settinghas been performed, the printing apparatus automatically analyzes theitem data, the delimiter, the print start command included in thereceived data whenever the printing apparatus receives data from thehost apparatus. Therefore, the template where the item data included inthe received data has been input to the input items can be set to be inan appropriate state.

Japanese Patent Application Laid-open No. 5-199990 and Japanese PatentApplication Laid-open No. 2004-330688 disclose a printing apparatuswhich automatically analyzes data received from a host computer.

However, if a configuration of data received from the host apparatus isunknown to the user, it is difficult for the user to preliminaryregister a delimiter character, a print start character and the likewhich are used by the host apparatus. Therefore, even if the printingapparatus receives data from the host apparatus, the item data, thedelimiter or the print start command included in the received datacannot be identified correctly. Thus, the template where the item dataincluded in the received data is input to the input items cannot be setto be in an appropriate state.

SUMMARY

The disclosure has been made in view of the above circumstances and hasan object to overcome the above problems and to provide a printingapparatus and a computer program product which can set a template in astate where item data included in received data is appropriately inputto input items of the template even if a configuration of received datais unknown to a user.

To achieve the purpose of the disclosure, there is provided a printingapparatus comprising: a template storing device that stores a templatehaving a plurality of input items; a receiving device that receivesreceived data; a defining data candidate obtaining device that obtainsfrom the received data at least one candidate for defining data whichdefines the received data into a plurality of groups based on the numberof the input items; a data candidate provisionally determining devicethat makes provisional determination based on the candidate for thedefining data; a first print data producing device that produces firstprint data by delimiting the received data into a plurality ofdelimiting data based on the provisional determination by the datacandidate provisionally determining device and inputting each of thedelimiting data to each of the input items of the template; and adisplay device that displays a print image of the first print data.

In the printing apparatus of the disclosure, when the printing apparatusreceives data, at least one candidate for defining data which definesthe received data into a plurality of groups is obtained from thereceived data based on the number of the input items of the template.The provisional determination is made based on the candidate for thedefining data. The first print data is produced by delimiting thereceived data into a plurality of delimiting data based on theprovisional determination and inputting each of the delimiting data toeach of the input items. The print image corresponding to the firstprint data is displayed. Therefore, the user can see the print image ofthe template where each delimiting data included in the received data isinput to each. of the input items and the user can check whether or notthe template where each delimiting data included in the received data isinput to each input item is in an appropriate state.

There is also provided a computer program product that is used andexecuted by a printing apparatus, comprising: a recording medium thatcan be read by a computer; and a computer program stored in therecording medium that can be read by the computer, wherein the computerprogram comprises: a receiving step of receiving received data with areceiving device; a defining data candidate obtaining step of obtainingat least one candidate for defining data which defines the received datainto a plurality of groups based on the number of input items of thetemplate that are stored in a template storing device; a data candidateprovisionally determining step of making provisional determination basedon the candidate for the defining data; a first print data producingstep of producing first print data by delimiting the received data intoa plurality of delimiting data based on the provisional determination bythe data candidate provisionally determining step and inputting each ofthe delimiting data to each of the input items of the template; and adisplay step of displaying a print image of the first print data on adisplay device.

In the computer program product of the disclosure, when the printingapparatus receives data, at least one candidate for defining data whichdefines the received data into a plurality of groups is obtained fromthe received data based on the number of the input items of thetemplate. The provisional determination is made based on the candidatefor the defining data. The first print data is produced by delimitingthe received data into a plurality of delimiting data based on theprovisional determination and inputting each of the delimiting data toeach of the input items. The print image corresponding to the firstprint data is displayed. Therefore, the user can see the print image ofthe template where each delimiting data included in the received data isinput to each of the input items and the user can check whether or notthe template where each delimiting data included in the received data isinput to each input item is in an appropriate state.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a view showing characteristics of a printing apparatusaccording to an embodiment;

FIG. 2 is a view showing an example of printing preview shown by theprinting apparatus according to the present embodiment;

FIG. 3 is a perspective view showing an outer appearance of the printingapparatus according to the present embodiment;

FIG. 4 is a block diagram showing a control system of the printingapparatus according to the present embodiment;

FIG. 5 is a flowchart of a main program;

FIG. 6 is a flowchart of a mode process;

FIG. 7 is a flowchart of a data process;

FIG. 8 is a flowchart of a print command analysis process;

FIG. 9 is a flowchart of a delimiter character string candidatedetermination process;

FIG. 10 is a flowchart of a print start character string candidatedetermination process;

FIG. 11 is a flowchart of a display variable initializing process;

FIG. 12 is a flowchart of a print preview display process;

FIG. 13 is a flowchart of a display renewal process;

FIG. 14 is a flowchart of a print data producing process;

FIG. 15 is a flowchart of another print command analysis process; and

FIG. 16 is a flowchart of another display renewal process.

DETAILED DESCRIPTION

A detailed description of an exemplary embodiment of. a printingapparatus of the disclosure will now be given referring to theaccompanying drawings. As shown in FIG. 1, in a printing apparatus 1 ofthe present embodiment, a template 40 having four input items 41, 42,43, 44 is stored in a flash ROM 14. A print preview 61 is shown on a LCD23. The print preview 61 shows a state where received data 51 from ahost apparatus 39 is input to each of the input items 41, 42, 43, 44 ofthe template 40.

The received data 51 from the host apparatus 39 (for example,“100/50/200/350CR”) includes three delimiters (for example, “/”, “/” and“/”) for limiting each item data and a print start character stringwhich corresponds to a print start command (specifically, “CR”), inaddition to four item data each of which is input to each of the inputitems 41, 42, 43, 44 of the template 40 (specifically, “100”, “50”,“200” and “350”). “CR” is an abbreviation of a carriage return code andrepresents one code. The carriage return code is one of control codes ofASCII code.

However, the printing apparatus 1 of the present embodiment cannotrecognize a delimiter or a print start character string included in thereceived data 51 from the host apparatus 39. Since the number ofdelimiters included in the received data 51 from the host apparatus 39is smaller than the number of the input items of the template 40 by one,the printing apparatus 1 of the present embodiment calculates that thereceived data 51 from the host apparatus 39 includes three delimiters.The printing apparatus 1 obtains a character string (specifically, “/”and “0/”), which is periodically repeated the number of times (threetimes) same as the number of the delimiters (three), from the receiveddata 51 from the host apparatus 39 and determines the character stringas a delimiter candidate. Further, the printing apparatus 1 obtains aprint start character string candidate (specifically, “CR”, “0CR”,“50CR” and “350CR”) based on the data group (specifically, “350CR”)which is located after the last delimiter candidate in the received data51 from the host apparatus 39.

A delimiter candidate and a print start character string candidate areprovisionally determined. The four item data included in the receiveddata 51 from the host apparatus 39 are presumed with using theprovisionally determined candidates for a delimiter and a print startcharacter string. The LCD 23 displays a print preview 61 which shows astate where the four item data are input to the input items 41, 42, 43,44 of the template 40.

At this time, if the print preview 61 displayed on the LCD 23 is in anappropriate state, the user operates an operation key 21 so as to printa print tape 52 as shown by the print preview 61.

Total number of combinations of the provisionally determined candidatesfor the delimiter and the print start character string is eight (2*4),since the number of the delimiter candidates (for example, “/” “0/”) istwo and the number of the print start character string candidates (forexample, “CR ” “0CR” “50CR” “350CR”) is four. Therefore, the number ofthe print previews displayed on the LCD 23 is also eight. The eighttypes of print previews are shown in FIG. 2.

The print preview 61A is shown on the LCD 23 when “/” is provisionallydetermined to be the delimiter candidate and “CR” is provisionallydetermined to be the print start character string candidate. The printpreview 61A is same as the print preview 61 shown in FIG. 1. The printpreview 61B is shown on the LCD 23 when “/” is provisionally determinedto be the delimiter candidate and “0CR” is provisionally determined tobe the print start character sting candidate. The print preview 61C isshown on the LCD 23 when “/” is provisionally determined to be thedelimiter candidate and “50CR” is provisionally determined to be theprint start character sting candidate. The print preview 61D is shown onthe LCD 23 when “/” is provisionally determined to be the delimitercandidate and “350CR” is provisionally determined to be the print startcharacter sting candidate.

The print preview 61E is shown on the LCD 23 when “0/” is provisionallydetermined to be the delimiter candidate and “CR” is provisionallydetermined to be the print start character sting candidate. The printpreview 61F is shown on the LCD 23 when “0/” is provisionally determinedto be the delimiter candidate and “0CR” is provisionally determined tobe the print start character sting candidate. The print preview 61G isshown on the LCD 23 when “0/” is provisionally determined to be thedelimiter candidate and “50CR” is provisionally determined to be theprint start character sting candidate. The print preview 61H is shown onthe LCD 23 when “0/” is provisionally determined to be the delimitercandidate and “350CR” is provisionally determined to be the print startcharacter sting candidate.

In the printing apparatus 1 shown in FIG. 1, when the user operates theoperation key 21, a combination of the provisionally determinedcandidates for the delimiter and the print start character string isrenewed. Therefore, if the user repeatedly operates the operation key21, the eight types of the print previews 61 are displayed on the LCD 23one by one. When the print preview 61 displayed on the LCD 23 is in anappropriate state, the user operates the operation key 21 so as to printthe image of the print preview 61 which is in an appropriate state onthe print tape 52.

A fractional number is displayed at an upper portion of each printpreview 61 so as to specify each of the print previews 61. For example,the fractional number of “⅛” displayed at the upper portion of the printpreview 61A means that the displayed print preview is a first type ofthe eight types of the print previews. The fractional number of “ 2/8”displayed at the upper portion of the print preview 61B means that thedisplayed print preview is a second type of the eight types of the printpreviews. Each of the fractional numbers of “⅜”, “ 4/8”, “⅝”, “ 6/8”,“⅞” and “ 8/8” displayed at the upper portion of the print preview 61C,61D, 61E, 61F, 61G and 61H is similar to the fractional number of “⅛” or“ 2/8”.

A configuration of the printing apparatus 1 according to the presentembodiment will be explained. As shown in FIG. 3, the printing apparatus1 of the present embodiment is a handy type label printer. A command key3, an upward key 4, a downward key 5, editing keys 6, a manual lever 7for cutting a print tape 52, a connection port 8 for receiving aconnector of a cable for connecting the printing apparatus 1 to the hostapparatus 39 and the like are arranged on a body frame 2 of the printingapparatus 1. The operation key 21 is comprised of the command key 3, theupward key 4, the downward key 5 and the editing keys 6.

Next, a control system of the printing apparatus 1 of the presentembodiment will be explained. As shown in FIG. 4, a CPU 12 for executingeach of programs which will be described later, a ROM 13, a flash ROM14, a RAM 15 and the like are connected to an input/output interface 11of the printing apparatus 1 of the present embodiment.

The ROM 13 stores various programs which will be described later. Theflash ROM 14 stores information relating to the template 40. The RAM 15includes a print buffer 16, a text buffer 17 and a work area which isused when the CPU 12 executes each of the programs. A mode flag, avariable x, a variable y, a variable i and a variable j are set in thework area.

In the printing apparatus 1 of the present embodiment, the operation key21, a display controller (referred to LCDC) 22, a drive circuit 24, adrive circuit 26 and the like are connected to the input/outputinterface 11. The display controller 22 has a display RAM for outputtingdisplay data to the LCD 23. The drive circuit 24 drives a thermal head25. The drive circuit 26 drives a tape feeding motor 27 which feeds theprint tape 52 from a print cassette to outside. The host apparatus 39 isconnected to the input/output interface 11 via a cable whose connectoris inserted to the connection port 8.

Next, control operations of the printing apparatus 1 of the presentembodiment will be explained. When the CPU 12 reads and executes a mainprogram, it is determined whether or not the CPU 12 receives data fromthe host apparatus 39 in step S11, as shown in FIG. 5. If it isdetermined that the CPU 12 received data from the host apparatus 39(S11: YES), the data processing of step S12 which will be describedlater is executed and the routine returns to step S11. The CPU 12 storesthe received data 51 from the host apparatus 39 in the work area of theRAM 15. On the other hand, if it is determined that the CPU 12 does notreceive data from the host apparatus 39 (S11: NO), the routine proceedsto step S13.

In step S13, the CPU 12 determines whether or not the editing key isoperated by the user. The editing key means the operation keys 21 exceptfor the command key 3. If it is determined that the editing key isoperated by the user (S13: YES), the routine proceeds to step S14. Aftera character, a number or a symbol is input by the operation of theediting key by the user in step S14, the routine returns to step S11.The input of a character, a number or a symbol by the operation of theediting key by the user means inputting or editing a content to beprinted, which has been known, and therefore detailed explanationthereof will be omitted. If it is determined that the editing key is notoperated by the user (S13: NO), the routine proceeds to step S15.

In step S15, the CPU 12 determines whether the mode key is operated bythe user. The mode key means the command key 3. If it is determined thatthe mode key is operated by the user (S15: YES), the routine returns tostep S11 after executing the mode process of step S16 which will bedescribed later. On the other hand, if it is determined that the modekey is not operated by the user (S15: NO), the routine proceeds to stepS17 and returns to step S11 after executing other processes.

The mode process of step S16 will be explained. When the mode process ofstep S16 is executed in the main program, the CPU 12 determines whetheror not the mode flag is on in step S21 shown in FIG. 6. The mode flag isset in the work area of the RAM 15 and the initial state of the modeflag is off. If it is determined that the mode flag is on (S21: YES),the routine proceeds to step S22. In step S22, the CPU 12 sets the modeflag to be off and the routine returns to step S11 in the main program.On the other hand, if it is determined that the mode flag is not on(S21: NO), the routine proceeds to step S23. In step S23, the CPU 12sets the mode flag to be on and the routine returns to step S11 in themain program.

The data processing of step S12 in the main program will be explained.When the data processing of step S12 in the main program is executed,the CPU 12 determines whether or not the mode flag is on in step S31shown in FIG. 7.

If it is determined that the mode flag is on (S31: YES), the routineproceeds to step S32. In step S32, the CPU 12 executes the print commandanalysis process and the routine returns to step S11 in the mainprogram. On the other hand, if it is determined that the mode flag isnot on (S31: NO), the routine proceeds to step S33. In step S33, the CPU12 executes the print data producing process which will be describedlater and the routine proceeds to step S34. In step S34, the CPU 12executes a normal printing operation and the routine returns to step S11in the main program. During the normal printing operation, the CPU 12drives the tape feeding motor 27 via the drive circuit 26 so as to feedthe print tape 52 to the outside of the print cassette and the CPU 12prints the print image, which is developed in the print buffer 16, onthe print tape 52 stored in the print cassette with the thermal head 25which is driven via the drive circuit 24.

Next, the print command analysis processing of step S32 in the dataprocessing shown in FIG. 7 will be explained. If the print commandanalysis processing of step S32 in the data processing shown in FIG. 7is executed, the CPU 12 obtains the number of delimiters from thetemplate 40 in step S41, shown in FIG. 8. In the case of FIG. 1, the CPU12 obtains the number (three) which is smaller than the number (four) ofthe input items 41, 42, 43, 44 of the template 40 by one as the numberof delimiters included in the received data 51 from the host apparatus39.

The template 40 is selected in the other processing of step S17 in themain program shown in FIG. 5.

Thereafter, the routine proceeds to step S42 and the CPU 12 determineswhether or not the number of delimiters is two or more. If it isdetermined that the number of delimiters is smaller than two (S42: NO),the routine proceeds to the delimiter character string candidatedetermining process of step S46 which will be described later. On theother hand, it is determined that the number of delimiters is two ormore (S42: YES), the routine proceeds to step S43. In the case of FIG.1, the received data 51 from the host apparatus 39 has three delimiters(S41) and the routine proceeds to step S43.

In step S43, the CPU 12 determines whether or not character strings ofthe same number as the number of delimiters are periodically included inthe received data 51 from the host apparatus 39. If it is determinedthat character strings of the same number as the number of delimitersare periodically included in the receive data 51 (S43: YES), the routineproceeds to the delimiter character string candidate determining processof step S46 which will be described below. In the case of FIG. 1, sincethe character string of “/” or “0/” is periodically included in thereceived data 51, the routine proceeds to the delimiter character stringcandidate determining process of step S46. On the other hand, if it isdetermined that character strings of the same number as the number ofdelimiters are not periodically included in the received data 51 (S43:NO), the routine proceeds to step S44.

In step S44, the CPU 12 displays an error on the LCD 23. Thereafter, theCPU 12 waits until any one of the operation keys 21 is depressed in stepS45 (S45: NO). If it is determined that any one of the operation keys 21is depressed (S45: YES), the routine returns to step S11 in the mainprogram.

If it is determined that the number of delimiters is less than two instep S42 (S42: NO) or that character strings of the same number as thenumber of delimiters are periodically included in the received data instep S43 (S43: YES), the routine proceeds to the delimiter characterstring candidate determining process of step S46. The delimitercharacter string candidate determining process of step S46 will beexplained.

When the delimiter character string candidate determining process ofstep S46 is executed in step S61 shown in FIG. 9, the CPU 12 searches adelimiter candidate and stores the searched delimiter candidate in thework area of the RAM 15 and stores the number of the searched delimitercandidates in the variable x which is set in the work area of the RAM15. The delimiter candidate is a character string which is an object forthe determination of step S43 in FIG. 8. Therefore, in the case of FIG.1, “/” or “0/” is a delimiter candidate and the number of delimitercandidates is two.

Thereafter, the routine returns to the print command analysis process ofFIG. 8 and proceeds to the print start character string candidatedetermining process of step S47. The print start character stringcandidate determining process of step S47 will be explained.

When the print start character string candidate determining process ofstep S47 is executed in step S71 shown in FIG. 10, the CPU 12 searches aprint start character string candidate and stores the searched candidatein the work area of the RAM 15 and stores the number of the searchedprint start character string candidates in the variable y which is setin the work area of the RAM 15. A print start character string candidateis obtained from a data group which is located after a last delimitercandidate in the received data. In the case of FIG. 1, considering that“/” or “0/” is a delimiter candidate, “CR”, “0CR”, “50CR” and “350CR”are the print start character string candidates and the number of theprint start character string candidates is four.

Thereafter, the routine returns to the print command analysis process ofFIG. 8 and proceeds to the display variable initialization process ofstep S48. The display variable initialization process of step S48 willbe explained.

When the display variable initialization process of step S48 isexecuted, the CPU 12 initializes the variable i which is set in the workarea of the RAM 15 in step S81 shown in FIG. 11. At this time, the CPU12 determines correlation between a delimiter candidate and the variablei and stores the determined correlation in the work area of the RAM 15.In the case of FIG. 1, for example, “0” corresponds to the value of thevariable i with respect to the delimiter candidate “/”, and “1”corresponds to the value of the variable i with respect to the delimitercandidate “0/”. When the routine proceeds to step S82, the CPU 12initializes the variable j which is set in the work area of the RAM 15.The CPU 12 determines correlation between a print start character stringcandidate and the variable j and stores the determined correlation inthe work area of the RAM 15. In the case of FIG. 1, for example, “0”corresponds to the value of the variable j with respect to the printstart character string candidate “CR”. “1” corresponds to the value ofthe variable j with respect to the print start character stringcandidate “0CR”. “2” corresponds to the value of the variable j withrespect to the print start character string candidate “50CR”. “3”corresponds to the value of the variable j with respect to the printstart character string candidate “350CR”. When the variables i and j areinitialized, “0” is set to the variables i and j.

The values of the variables i and j are also used for displayingfractions at the upper portion of the print preview 61 (see FIG. 2).

Thereafter, the routine returns to the print command analysis process ofFIG. 8 and proceeds to the print preview display process of step S49.The print preview display process of step S49 will be explained.

When the print preview display process of step S49 is executed, the CPU12 provisionally determines a delimiter and a print start characterstring in step S91 of FIG. 12. The CPU 12 provisionally determines adelimiter candidate corresponding to the value of the variable i and aprint start character string candidate corresponding to the value of thevariable j. For example, when the value of the variable i is “0”, acorresponding candidate for the delimiter “/” is provisionallydetermined. When the value of the variable j is “0”, a correspondingcandidate for the print start character string “CR” is provisionallydetermined.

When the routine proceeds to step S92, the CPU 12 produces print data.That is, the CPU 12 inputs the received data to the input item 41 of thetemplate 40 from its beginning to data which is located just before aprovisionally determined delimiter candidate (first candidate). Then,the CPU 12 inputs the received data to the input item 42 of the template40 from data which is located just after the delimiter candidate (firstcandidate) to data which is located just before the provisionallydetermined delimiter candidate (second candidate). Then, the CPU 12inputs the received data to the input item 43 of the template 40 fromdata which is located just after the delimiter candidate (secondcandidate) to data which is located just before the provisionallydetermined delimiter candidate (third candidate). Further, the CPU 12inputs the received data to the input item 43 of the template 40 fromdata which is located just after the delimiter candidate (thirdcandidate) to data which is located just before a provisionallydetermined print start character string candidate. The CPU 12 storesthus produced print data in the text buffer 17. Then, the CPU 12develops a print image in the print buffer 16 based on the print data.

Thereafter, when the routine proceeds to step S93, the CPU 12 displays aprint preview of the print image which is developed in the print buffer16 on the LCD 23.

Specifically, in the case of FIG. 1, when a candidate for the delimiter“/” is provisionally determined and a candidate for the print startcharacter string “CR” is provisionally determined, the CPU 12 inputs thereceived data 51 (“100/50/200/350CR”) from the host apparatus 39 to theinput item 41 of the template 40 from its beginning data of “1” to thedata of “0” which is located just before the provisionally determinedcandidate for the delimiter “/” (first candidate). As a result, data of“100” is input to the input item 41 of the template 40. Then, the CPU 12inputs the received data 51 (“100/50/200/350CR”) from the host apparatus39 to the input item 42 of the template 40 from the data of “5” which islocated just after the candidate for the delimiter “/” (first candidate)to the data of “0” which is located just before the provisionallydetermined candidate for the delimiter “/” (second candidate). As aresult, data of “50” is input to the input item 42 of the template 40.Then, the CPU 12 inputs the received data 51 (“100/50/200/350CR”) fromthe host apparatus 39 to the input item 43 of the template 40 from thedata of “2” which is located just after the candidate for the delimiter“/” (second candidate) to the data of “0” which is located just beforethe provisionally determined candidate for the delimiter “/” (thirdcandidate). As a result, data of “200” is input to the input item 43 ofthe template 40. Further, the CPU 12 inputs the received data 51(“100/50/200/350CR”) from the host apparatus 39 from the data of “3”which is located just after the candidate for the delimiter “/” (thirdcandidate) to the data of “0” which is located just before theprovisionally determined candidate for the print start character sting“CR”. As a result, the data of “350” is input to the input item 44 ofthe template 40.

Thus produced print data is stored in the text buffer 17 and a printimage which is produced based on the print data is developed in theprint buffer 16. The print preview 61A of the print image is displayedon the LCD 23.

Thereafter, the routine returns to the print command analysis process ofFIG. 8 and proceeds to step S50. In step S50, the CPU 12 waits until anyone of the operation keys 21 is depressed (S50: NO). When any one of theoperation keys 21 is depressed (S50: YES), the routine proceeds to stepS51.

In step S51, the CPU 12 determines whether or not the operation key 21depressed in step S50 is an OK key. The OK key is a command key 3(commonly used with the mode key). If it is determined that theoperation key 21 depressed in step S50 is not an OK key (S51: NO), theroutine proceeds to step S52.

In step S52, the CPU 12 determines whether or not the upward key 4 orthe downward key 5 is depressed. If none of the upward key 4 and thedownward key 5 is depressed (S52: NO), the routine returns to step S49.On the other hand, if it is determined that any one of the upward key 4and the downward key 5 is depressed (S52: YES), the routine proceeds tothe display renewal process of step S53.

The display renewal process of step S53 will be explained. When thedisplay renewal process of step S53 is executed, the CPU 12 determineswhether or not the upward key 4 is depressed in step S101 of FIG. 13. Ifit is determined that the upward key 4 is depressed (S101: YES), theroutine proceeds to step S102. In step S102, the CPU 12 determineswhether or not the value of the variable i is smaller than the valueobtained by subtracting “1” from the value of the variable x. If it isdetermined that the value of the variable i is smaller than the valueobtained by subtracting “1” from the value of the variable x (S102:YES), the routine proceeds to step S103. In step S103, the CPU 12increments the value of the variable i. Then, the routine returns to theprint command analysis process of FIG. 8 and proceeds to the printpreview display process of step S49.

On the other hand, in step S102, if it is determined that the value ofthe variable i is equal to or greater than the value obtained bysubtracting “1” from the value of variable x (S102: NO), the routineproceeds to step S104. In step S104, the CPU 12 determines whether ornot the value of the variable j is smaller than the value obtained bysubtracting “1” from the value of the variable y. If it is determinedthat the value of the variable j is smaller than the value obtained bysubtracting “1” from the value of the variable y (S104: YES), theroutine proceeds to step S105. In step S105, the CPU 12 initializes thevariable i and increments the value of the variable j. Thereafter, theroutine returns to the print command analysis process of FIG. 8 andproceeds to the print preview display process of step S49.

In step S104, it is determined that the value of the variable j is equalto or greater than the value obtained by subtracting “1” from the valueof the variable y (S104: NO), the routine proceeds to step S106. In stepS106, the CPU 12 initializes the variables i and j. Thereafter, theroutine returns to the print command analysis process of FIG. 8 andproceeds to the print preview display process of step S49.

In step S101, when it is determined that the upward key 4 is notdepressed (S101: NO), the routine proceeds to step S107. In step S107,the CPU 12 determines whether or not the value of the variable i isgreater than “0”. If it is determined that the value of the variable iis greater than “0” (S107: YES), the routine proceeds to step S108. Instep S108, the CPU 12 decrements the value of the variable i.Thereafter, the routine returns to the print command analysis process ofFIG. 8 and proceeds to the print preview display process of step S49.

In step S107, if it is determined that the value of variable i is “0”(S107: NO), the routine proceeds to step S109. In step S109, the CPU 12determines whether or not the value of the variable j is greater than“0”. If it is determined that the value of the variable j is greaterthan “0” (S109: YES), the routine proceeds to step S110. In step S110,the CPU 12 sets the value obtained by subtracting “1” from the value ofvariable x to the variable i and decrements the value of the variable j.Thereafter, the routine returns to the print command analysis process ofFIG. 8 and proceeds to the print preview display process of step S49.

In step S109, if it is determined that the value of the variable j is“0” (S109: NO), the routine proceeds to step S111. In step S111, the CPU12 sets the value obtained by subtracting “1” from the value of variablex to the variable i and sets the value obtained by subtracting “1” fromthe value of the variable y to the variable j. Thereafter, the routinereturns to the print command analysis process of FIG. 8 and proceeds tothe print preview display process of step S49.

Therefore, when the display renewal process is executed in the case ofFIG. 1, by depression of the upward key 4 or the downward key 5, each ofthe values (i, j) of the variables i and j is set to be any ofcombinations of (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2)and (1, 3). By executing the display renewal process, each of the values(i, j) of the variables i and j is renewed. Thereafter, the routinereturns to the print command analysis process of FIG. 8 and proceeds tothe print preview display process of step S49. When step S91 in FIG. 12is executed, the provisionally determined delimiter and print startcharacter string is renewed.

The routine returns to the print command analysis process of FIG. 8 andif it is determined that the operation key 21 depressed in step S50 isan OK key in step S51 (S51: YES), the routine proceeds to step S54. Instep S54, the CPU 12 sets the provisionally determined current delimitercandidate as the delimiter and sets the provisionally determined currentprint start character string candidate as the print start characterstring. Thereafter, the routine returns to step S11 of the main program.

The print data producing process of step S33 in the data processing ofFIG. 7 will be explained. When the print data producing process of stepS33 is executed, the CPU 12 obtains the delimiter and the print startcharacter string in step S121 as shown in FIG. 14. The obtaineddelimiter and print start character string are the ones set in step S54.

Thereafter, the CPU 12 proceeds to step S122 and produces print data.The CPU 12 inputs the received data to the input item 41 of the template40 from its beginning to the data which is located just before theobtained delimiter (first delimiter). The CPU 12 inputs the receiveddata to the input item 42 of the template 40 from the data which islocated just after the delimiter (first delimiter) to the data which islocated just before the obtained delimiter (second delimiter). The CPU12 inputs the received data to the input item 43 of the template 40 fromthe data which is located just after the delimiter (second delimiter) tothe data which is located just before the obtained delimiter (thirddelimiter). Further, the CPU 12 inputs the received data to the inputitem 44 of the template 40 from the data which is located just after thedelimiter (third delimiter) to the data which is located just before theobtained print start character string. The CPU 12 stores thus producedprint data in the text buffer 17. Thereafter, the CPU 12 develops aprint image based on the print data in the print buffer 16.

Specifically, in the case of FIG. 1, when the delimiter of “/” is setand the print start character string of “CR” is set, the CPU 12 inputsthe received data 51(“100/50/200/350CR”) from the host apparatus 39 tothe input item 41 of the template 40 from its beginning data of “1” tothe data of “0” which is located just before the set delimiter “/”(first delimiter). As a result, the data of “100” is input to the inputitem 41 of the template 40. The CPU 12 inputs the received data 51(“100/50/200/350CR”) from the host apparatus 39 to the input item 42 ofthe template 40 from the data of “5” which is located just after thedelimiter “/” (first delimiter) to the data of “0” which is located justbefore the set delimiter “/” (second delimiter). As a result, the dataof “50” is input to the input item 42 of the template 40. The CPU 12inputs the received data 51 (“100/50/200/350CR”) from the host apparatus39 to the input item 43 of the template 40 from the data of “2” which islocated just after the delimiter “/” (second delimiter) to the data of“0” which is located just before the set delimiter “/” (thirddelimiter). As a result, the data of “200” is input to the input item 43of the template 40. Further, The CPU 12 inputs the received data 51(“100/50/200/350CR”) from the host apparatus 39 to the input item 44 ofthe template 40 from the data of “3” which is located just after thedelimiter “/” (third delimiter) to the data of “0” which is located justbefore the print start character string “CR”. As a result, the data of“350” is input to the input item 44 of the template 40. Thus producedprint data is stored in the text buffer 17 and a print image which isproduced based on the print data is developed in the print buffer 16.

Thereafter, the routine returns to the data processing of FIG. 7 andproceeds to step S34. In step S34, the print image developed in theprint buffer 16 is printed on a print tape 52, as described above.Thereafter, the routine returns to step S11 of the main program shown inFIG. 5.

As described above, in the printing apparatus 1 of the presentembodiment, if the CPU 12 receives data 51 (specifically,“100/50/200/350CR”) from the host apparatus 39 (S11: YES), the CPU 12obtains from the received data 51 a delimiter candidate for defining thereceived data 51 into a plurality of groups (S61). The number of thedelimiters included in the received data 51 (three) must be less thanthe number of the input items 41, 42, 43, 44 of the template 40 (four)by one. The character string, which is periodically repeated in thereceived data 51 (specifically, “/” and “0/”) the same number of times(three times) as the number of the delimiters (three) which iscalculated based on the number of the input items 41, 42, 43, 44 of thetemplate 40 (four), is searched. The searched character string is set tobe a delimiter candidate.

Further, candidates for a print start character string which representsan end of the received data 51 (specifically, “CR”, “0CR”, “50CR” and“350CR”) are obtained from a data group which is located after the lastdelimiter candidate in the received data 51 (specifically, “350CR”)(S71). Thereafter, each of a delimiter candidate and a print startcharacter string candidate is provisionally determined (S91). Based onthe provisionally determined delimiter candidate and the provisionallydetermined print start character string candidate, the received data 51is delimited so as to be input to the input items 41, 42, 43, 44 of thetemplate 40. Thereby, the print data is produced. A print image isproduced based on the thus produced print data and the print image isdeveloped in the print buffer 16 (S92). The print preview 61 accordingto the print image is displayed on the LCD 23 (S93).

Therefore, the user can check whether or not the print data which isproduced based on the provisionally determined delimiter candidate andthe provisionally determined print start character string candidate isappropriate by seeing the print preview 61 displayed on the LCD 23.

Since the print data is produced based on the print start characterstring candidate, the print start character string in the received data51 is not input to the input items 41, 42, 43, 44 of the template 40.Therefore, the produced print data is likely to be in a state where thereceived data 51 is appropriately input to the input items 41, 42, 43,44 of the template 40.

In the printing apparatus 1 of the present embodiment, if the userdepresses the upward key 4 or the downward key 5 (S52: YES), the valueof the variable i corresponding to each delimiter candidate or the valueof the variable j corresponding to each print start character stringcandidate is changed (S53), and thereby the provisionally determineddelimiter candidate or the provisionally determined print startcharacter string candidate is also changed (S91). New print data isproduced based on the changed delimiter candidate or the changed printstart character string candidate. A print image is produced based on thenewly produced print data and the print image is developed in the printbuffer 16 (S92). The print preview 61 based on the print image isdisplayed on the LCD 23 (S93).

Therefore, if the user checks the print preview 61 displayed on the LCD23 and determines that the print data produced based on theprovisionally determined delimiter candidate and the provisionallydetermined print start character string candidate is not appropriate,the user depresses the upward key 4 or the downward key 5 so as tochange the delimiter candidate or the print start character stringcandidate. Accordingly, the print preview 61 of the print data which isnewly produced based on the changed delimiter candidate and the changedprint start character string candidate. Thus, the delimiter candidate orthe print start character string candidate is changed until appropriateprint data is produced based on a delimiter candidate and a print startcharacter string candidate.

In the printing apparatus 1 of the present embodiment, if the userdepresses the command key 3 (S51: YES), the current delimiter candidateis set to be a delimiter and the current print start character stringcandidate is set to be a print start character string (S54). Print datais produced based on the set delimiter and print start character string(S122). Thus produced print data is stored in the text buffer 17 and aprint image produced based on the print data is developed in the printbuffer 16 and printed on a print tape 52 (S34).

If the user checks the print preview 61 displayed on the LCD 23 anddetermines that the print data produced based on the delimiter candidateand the print start character string candidate is appropriate, the userdepresses the command key 3 so as to print the template 40 where thereceived data 51 is appropriately input to the input items 41, 42, 43,44 on a print tape 52. Therefore, the user is not required to know thedelimiter and the print start character string included in the receiveddata 51 and the user is not required to preliminary set a delimiter anda print start character string included in the received data 51 to theprinting apparatus 1. Further, if the user depresses the command key 3once, a delimiter candidate and a print start character string candidatewhich produce appropriate print data are specified. Therefore, thetemplate 40 where the received data 51 is appropriately input to theinput items 41, 42, 43, 44 is printed on a print tape 52 withoutrepeating the depression of the command key 3.

The disclosure may be embodied in other specific forms without departingfrom the sprit or essential characteristics thereof.

For example, in the printing apparatus 1 of the present embodiment,instead of the print command analysis process of FIG. 8 or the displayrenewal process of FIG. 13, the print command analysis process of FIG.15 or the display renewal process of FIG. 16 may be executed. The printcommand analysis process of FIG. 15 or the display renewal process ofFIG. 16 will be explained. Same symbols and numbers are applied to theparts which are common to the print command analysis process of FIG. 8or the display renewal process of FIG. 13 and the explanation thereofwill be omitted and only the different parts will be explained.

In the print command analysis process of FIG. 15, if the CPU 12determines that the character strings of the same number as the numberof the delimiters are not periodically included in the received data instep S43 (S43: NO), the routine proceeds to step S131. In step S131, thenumber of the delimiters is decremented and the routine returns to stepS42. If the CPU 12 determines that the upward key 4 or the downward key5 is depressed in step S52 (S52: YES), the routine proceeds to a displayrenewal process of step S132. The display renewal process of step S132corresponds to the display renewal process of FIG. 16.

In the display renewal process of FIG. 16, after the CPU 12 initializesthe variables i and j in step S106, the routine proceeds to step S141.In step S141, the CPU 12 determines whether or not the number ofdelimiters is an uppermost value. The uppermost value is the number ofdelimiters (three) obtained in step S41 of the print command analysisprocess of FIG. 15. If the CPU 12 determines that the number ofdelimiters is the uppermost value (S141: YES), the routine proceeds tostep S142. In step S142, the CPU 12 sets the number of delimiters to“0”. Then, the routine returns to the print command analysis process ofFIG. 15 and proceeds to step S133 which will be described later. On theother hand, in step S141, if the CPU 12 determines that the number ofdelimiters is not the uppermost value (S141: NO), the routine proceedsto step S143. In step S143, the CPU 12 increments the number ofdelimiters. Then, the routine returns to the print command analysisprocess of FIG. 15 and proceeds to step S133 which will be describedlater.

In the display renewal process of FIG. 16, if the CPU 12 determines thatthe value of the variable j is “0” in step S109 (S109: NO), the routineproceeds to step S144. In step S144, the CPU 12 initializes thevariables i and j and the routine proceeds to step S145. In step S145,the CPU 12 determines whether or not the number of delimiters is alowermost value. The lowermost value is “0”. If the CPU 12 determinesthat the number of delimiters is the lowermost value (S145: YES), theroutine proceeds to step S146. In step S146, the CPU 12 sets the numberof delimiters to the maximum value (uppermost value). Then, the routinereturns to the print command analysis process of FIG. 15 and proceeds tostep S133 which will be described later. On the other hand, in stepS145, if the CPU 12 determines that the number of delimiters is not thelowermost value (S145: NO), the routine proceeds to step S147. In stepS147, the CPU 12 decrements the number of delimiters. Then, the routinereturns to the print command analysis process of FIG. 15 and proceeds tostep S133 which will be described later.

When the routine returns to the print command analysis process of FIG.15 and proceeds to step S133, the CPU 12 determines whether or not thenumber of delimiters is changed. In step S133, it is determined whetheror not the number of delimiters is changed at the display renewalprocess of FIG. 16. If it is determined that the number of delimiters ischanged (S133: YES), the routine returns to step S42. On the other hand,if it is determined that the number of delimiters is not changed (S133:NO), the routine returns to step S49.

Then, when the print command analysis process of FIG. 15 or the displayrenewal process of FIG. 16 is executed, the received data 51 can beinput to the input items 41, 42, 43, 44 of the template 40 with thenumber of delimiters which is smaller than the number of delimiters(three) which is calculated based on the number of the input items 41,42, 43, 44 of the template 40 (four). Consequently, the received data 51may not be input to some of the input items 41, 42, 43, 44. However, thedata which has already input is used since the print data is produced bymaintaining the data which has been already input.

In the printing apparatus 1 of the present embodiment, in step S51 ofthe print command analysis process of FIG. 8 or FIG. 15, if it isdetermined that the operation key 21 depressed in step S50 is an OK key(S51: YES), the print image which is developed in the print buffer 16may be printed on a print tape 52 instead of executing step S54. In thiscase, the template 40 where the received data 51 is appropriately inputto each of the input items 41, 42, 43, 44 can be printed on a print tape52. Further, the processes relating to the mode in the main program ofFIG. 5 (S15, S16) can be omitted.

In the printing apparatus 1 of the present embodiment, the item data, adelimiter and a print start character string included in the data 51received from the host apparatus 39 may be comprised of data havingdifferent kinds. Specifically, in the received data 51 of“A1BC2DEF34GHIJCR”, the item data (“A”, “B”, “DEF” and “GHIJ”) iscomprised of alphabets and the delimiters (“1”, “2”, “3” and “4”) arecomprised of numbers and the print start character string (“CR”) iscomprised of a control code of an ASCII code. In this case of example,it can be recognized that no item data is between the delimiters “3” and“4”. It can be also recognized that no item data is after the delimiter“33” from the item data after the delimiter “3”. By comprising itemdata, a delimiter and a print start character string of data havingdifferent kinds, item data, a delimiter and a print start characterstring can be distinguished from each other precisely and adistinguishing process becomes simplified. The number of candidates foreach of a delimiter and a print start character string or the number ofcandidates for both of them can likely be reduced compared to a casewhere a kind of item data, a delimiter and a print start characterstring is unknown or comprised of same kind of data. Or, one candidatefor each of a delimiter and a print start character string can likely bedetermined, that is, a combination of item data, a delimiter and a printstart character string is likely to be determined.

The printing apparatus 1 of the present embodiment can cope with a casewhere no print start character string is included in the received data51 from the host apparatus 39. In this case, in the printing apparatus 1of the present embodiment, after an imaginary print start characterstring is added to an end of the received data 51 from the hostapparatus 39, the above-described main program and the like may beexecuted or the processes relating to the print start character stringmay be omitted from the above-described main program and the like andthe print data may be produced based on only a delimiter candidate. Inthis case also, the above-described effects can be obtained.

While the presently exemplary embodiment has been shown and described,it is to be understood that this disclosure is fro the purpose ofillustration and that various changes and modifications may be madewithout departing from the scope of the disclosure as set forth in theappended claims.

1. A printing apparatus comprising: a template storing device thatstores a template having a plurality of input items; a receiving devicethat receives received data; a defining data candidate obtaining devicethat obtains from the received data at least one candidate for definingdata which defines the received data into a plurality of groups based onthe number of the input items; a data candidate provisionallydetermining device that makes provisional determination based on thecandidate for the defining data; a first print data producing devicethat produces first print data by delimiting the received data into aplurality of delimiting data based on the provisional determination bythe data candidate provisionally determining device and inputting eachof the delimiting data to each of the input items of the template; and adisplay device that displays a print image of the first print data. 2.The printing apparatus according to claim 1, wherein each of thedefining data and the delimiting data is different kind of data.
 3. Theprinting apparatus according to claim 1, further comprising: a firstprinting device; and a first input device that is operated by an usersuch that the first printing device prints the print image of the firstprint data that is displayed on the display device.
 4. The printingapparatus according to claim 1, further comprising: a defining dataspecifying device which specifies the defining data; a second inputdevice that is operated by an user such that the defining dataspecifying device specifies the defining data based on the provisionaldetermination, wherein the first print data corresponding to the printimage that is displayed on the display device is produced based on theprovisional determination; a second print data producing device thatproduces second print data by delimiting the received data into aplurality of delimiting data based on the defining data and inputtingeach of the delimiting data to each of the input items of the template;and a second printing device that prints a print image of the secondprint data.
 5. The printing apparatus according to claim 1, furthercomprising: an end data candidate obtaining device that obtains at leastone candidate for end data representing an end of the received data fromthe received data based on a candidate for the defining data, whereinthe data candidate provisionally determining device makes provisionaldetermination based on a candidate for the defining data and a candidatefor the end data.
 6. The printing apparatus according to claim 5,wherein each of the defining data, the end data and the delimiting datais different kind of data.
 7. The printing apparatus according to claim5, further comprising a first printing device; and a first input devicethat is operated by an user such that the first printing device printsthe print image of the first print data that is displayed on the displaydevice.
 8. The printing apparatus according to claim 5, furthercomprising: a defining data specifying device which specifies thedefining data; a end data specifying device which specifies the enddata; a third input device that is operated by an user such that thedefining data specifying device specifies the defining data based on theprovisional determination and the end data specifying device specifiesthe end data based on the provisional determination, wherein the firstprint data corresponding to the print image that is displayed on thedisplay device is produced based on the provisional determination; athird print data producing device that produces third print data bydelimiting the received data into a plurality of delimiting data basedon the defining data and the end data and inputting each of thedelimiting data to each of the input items of the template; and a thirdprinting device that prints a print image of the third print data. 9.The printing apparatus according to claim 1, further comprising: afourth input device that is operated by an user to renew the provisionaldetermination made for the data candidate provisionally determiningdevice.
 10. The printing apparatus according to claim 1, wherein thefirst print data producing device produces the first print data even ifthe number of delimiting data is less than the number of input items ofthe template.
 11. A computer program product that is used and executedby a printing apparatus, comprising: a recording medium that can be readby a computer; and a computer program stored in the recording mediumthat can be read by the computer, wherein the computer programcomprises: a receiving step of receiving received data with a receivingdevice; a defining data candidate obtaining step of obtaining at leastone candidate for defining data which defines the received data into aplurality of groups based on the number of input items of the templatethat are stored in a template storing device; a data candidateprovisionally determining step of making provisional determination basedon the candidate for the defining data; a first print data producingstep of producing first print data by delimiting the received data intoa plurality of delimiting data based on the provisional determination bythe data candidate provisionally determining step and inputting each ofthe delimiting data to each of the input items of the template; and adisplay step of displaying a print image of the first print data on adisplay device.
 12. The computer program product according to claim 11,wherein each of the defining data and the delimiting data is differentkind of data.
 13. The computer program product according to claim 11,further comprising: a first printing step of printing the print image ofthe first print data that is displayed on the display device with afirst printing device when a first input device receives a command by anuser.
 14. The computer program product according to claim 11, furthercomprising: a defining data specifying step of specifying the definingdata based on the provisional determination by which the first printdata corresponding to the print image displayed on the display device isproduced when a second input device receives a command by an user; asecond print data producing step of producing second print data bydelimiting the received data into a plurality of delimiting data basedon the defining data and inputting each of the delimiting data to eachof the input items of the template; and a second printing step ofprinting a print image of the second print data with a second printingdevice.
 15. The computer program product according to claim 11, furthercomprising an end data candidate obtaining step of obtaining from thereceived data at least one candidate for end data representing an end ofthe received data based on a candidate for the defining data, wherein inthe data candidate provisionally determining step, the provisionaldetermination is made based on a candidate for the defining data and acandidate for the end data.
 16. The computer program product accordingto claim 15, wherein each of the defining data, the end data and thedelimiting data is different kind of data.
 17. The computer programproduct according to claim 15, further comprising: a first printing stepof printing a print image of the first print data that is displayed onthe display device with a first printing device when a first inputdevice receives a command by an user.
 18. The computer program productaccording to claim 15, further comprising: a defining data and end dataspecifying step of specifying the defining data and the end data basedon the provisional determination by which first print data correspondingto a print image displayed on the display device is produced, when athird input device receives a command by an user; a third print dataproducing step of producing third print data by delimiting the receiveddata into a plurality of delimiting data based on the defining data andthe end data and inputting each of the delimiting data to each of theinput items of the template; and a third printing step of printing aprint image of the third print data with a third printing device. 19.The computer program product according to claim 11, further comprising:a renewal step of renewing the provisional determination made in thedata candidate provisionally determining step when a fourth input devicereceives a command by an user.
 20. The computer program productaccording to claim 11, wherein in the first print data producing step,the first print data is produced even if the number of delimiting datais less than the number of input items of the template.